package edu.sias.course.controller;


import edu.sias.common.core.controller.BaseController;
import edu.sias.course.domain.dto.TagDTO;
import edu.sias.course.domain.entity.PageResult;
import edu.sias.course.domain.entity.QueryPageBean;
import edu.sias.course.domain.entity.TagPageQueryParams;
import edu.sias.course.service.TagService;
import edu.sias.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description TagController
 * @Author liu
 * @Date
 */
@RestController
@RequestMapping("/tag")
@Slf4j
@Api(tags = "学科标签相关接口")
public class TagController extends BaseController {

    @Resource
    private TagService tagService;

    @ApiOperation("学科标签添加接口")
    @PostMapping("/add.do")
    public AjaxResult add(@RequestBody TagDTO tagDTO){

        log.info("开始执行学科标签添加：{}",tagDTO);
        //调用业务
        tagService.add(tagDTO);
        //返回数据
        return AjaxResult.success("学科标签添加成功");
    }

    @ApiOperation("学科标签分页列表接口")
    @PostMapping("/findListByPage.do")
    public AjaxResult findListByPage(@RequestBody QueryPageBean<TagPageQueryParams> queryPageBean){
        log.info("开始执行学科标签分页列表接口：{}",queryPageBean);

        //调用业务
        PageResult pageResult = tagService.findListByPage(queryPageBean);

        return AjaxResult.success(pageResult);
    }


    @ApiOperation("学科标签删除接口")
    @GetMapping("/delete.do")
    public AjaxResult delete(Integer tagId){
        log.info("开始执行学科标签删除接口：{}",tagId);

        //调用业务
        tagService.deleteTag(tagId);

        //返回数据
        return AjaxResult.success( "学科标签删除成功");
    }

}
